package com.example.flutter_youren

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.example.flutter_youren.NativeConstant.MYHOME_PAGE
import com.example.flutter_youren.databinding.ActivityAndroidNativeBinding

class AndroidNativeActivity : Activity() {
    lateinit var binding: ActivityAndroidNativeBinding
    val startNativePageNum by lazy { intent.extras?.getInt("startNativePageNum") ?: 1 }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityAndroidNativeBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.btn2FlutterPage.setOnClickListener {
            val intent = Intent(this, MainActivity::class.java)
            intent.putExtra("startFlutterPageName", MYHOME_PAGE)
            intent.putExtra("nativeNum", startNativePageNum)
            startActivity(intent)
        }
        binding.btn2NativePage.setOnClickListener {
            val intent = Intent(this, AndroidNativeActivity::class.java)
            var index = startNativePageNum + 1
            intent.putExtra("startNativePageNum", index)
            startActivity(intent)
        }
        binding.tvNum.text = "Native Page:$startNativePageNum"
    }
}